package main

import (
	"io"
	"log"
	"net"
	"os"
)

func main()  {
	conn,err := net.Dial("tcp",":3000")
	if err != nil {
		panic(err)
	}
	done := make(chan int)
	
	go func() {
		_, _ = io.Copy(os.Stdout, conn)
		done <- 1
		log.Fatalln("用户退出")
	}()
	
	mustCopy(conn,os.Stdin)
	conn.Close()
	<-done
}

func mustCopy(dst io.Writer,src io.Reader){
	if _,err := io.Copy(dst,src);err != nil{
		log.Fatal(err)
	}
}
